#!/bin/bash

if [ $# -ne 1 ]; then
    echo "usage: $(basename $0) <dir>"
    echo "  Tries to remove all duplicate music files in <dir>"
    exit 1
fi

find "$1" -type f | while read FILE; do
    NoExten=$(echo "$FILE" | perl -pe 's/\.\S+$//') #remove extension from FILE
    # echo $FILE
    # echo $NoExten
    # echo ---
    
    for num in {1..3}; do
	rm -f "$NoExten $num.mp3"
	rm -f "$NoExten $num.m4a"
	rm -f "$NoExten $num.aac"
    done

done

